from selenium.webdriver.common.by import By

from Base.Base import Base
import time

#搜索业务
class Page(Base):
    #点击登录
    denglu_loc=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    #断言1“会员登录”
    dy1_loc=(By.CLASS_NAME,'class="reg-new"')
    #输入用户名和密码，等待7秒
    # user_loc=By.XPATH,'//*[@id="theForm"]/div[1]/span[2]/input'
    user_loc = (By.NAME, 'username')
    password_loc=(By.NAME,'password')
    #点击登录
    login_loc=(By.XPATH,'//a[@class="finish-btn"]')
    #断言2“欢迎回来”
    dy2_loc=(By.LINK_TEXT,'欢迎回来，liu121212')
    #点击搜索框 输入“￥%……￥R……&*”
    kuang_loc=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')
    #回车事件
    huiche_loc=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')

    def denglu(self):
        self.dianji_click(self.denglu_loc)
    def dy1(self):
        self.text_wenben(self.dy1_loc)
    def user(self):
        self.send_keys(self.user_loc,'liu121212')
    def password(self):
        self.send_keys(self.password_loc,'121212')
    def login(self):
        self.dianji_click(self.login_loc)
    def dy2(self):
        self.text_wenben(self.dy2_loc)
    def kuang(self):
        self.send_keys(self.kuang_loc,'￥%……￥R……&*')
    def huiche(self):
        self.ENTER(self.huiche_loc)



    def a3mall_search_01(self):
        self.open_url('http://10.59.9.12:7001/')
        self.denglu()

        # assert '会员登录' in self.dy1()
        # print(self.dy1())
        # time.sleep(4)

        self.user()
        self.password()
        time.sleep(7)

        self.login()

        # assert '欢迎回来，liu121212' in self.dy2()
        # print(self.dy2())
        # time.sleep(4)

        self.kuang()
        self.huiche()
